using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Localization;
/// <summary>
/// https://www.bilibili.com/video/BV1ya4y1G7DE/?p=11&spm_id_from=pageDriver
/// </summary>
public class ChageScore : MonoBehaviour
{
    [SerializeField] private LocalizedString localStringScore;
    [SerializeField] private Text text;

    private int score;

    private void OnEnable()
    {
        localStringScore.Arguments = new object[] { score };
        localStringScore.StringChanged += UpdateText;
    }

    private void OnDisable()
    {
        localStringScore.StringChanged -= UpdateText;
    }

    private void UpdateText(string value)
    {
        text.text = value;
    }

    public void IncreaseScore()
    {
        score++;
        localStringScore.Arguments[0] = score;
        localStringScore.RefreshString();
    }
}
